from django.db import router
from django.urls import path, re_path, include
from rest_framework.routers import DefaultRouter
from rest_framework_jwt.views import obtain_jwt_token

from .views import statistical, users, specs, images, skus, orders, permission, group, admin

app_name = 'meiduo_admin'
urlpatterns = [
    # 登录
    re_path(r'^authorizations/', obtain_jwt_token),
    # ————————————————————数据统计————————————————————————————
    # 用户总量统计
    re_path(r'^statistical/total_count/', statistical.UserCountView.as_view()),
    # 日增用户
    re_path(r'^statistical/day_increment/', statistical.UserDayCountView.as_view()),
    # 日活跃用户
    re_path(r'^statistical/day_active/', statistical.UserDayActiveCountView.as_view()),
    # 日下单
    re_path(r'^statistical/day_orders/', statistical.UserDayOrdersCountView.as_view()),
    # 月增用户
    re_path(r'^statistical/month_increment/', statistical.UserMonthIncrementCountView.as_view()),
    # 日分类商品访问量统计
    re_path(r'^statistical/goods_day_views/', statistical.GoodsDayView.as_view()),
    # ————————————————————用户管理模块————————————————————————————
    # 用户查询
    re_path(r'^users/$', users.UserView.as_view()),
    # spu查询
    re_path(r'^goods/simple/$', specs.SpecsView.as_view({'get': 'simple'})),
    # sku商品查询
    re_path(r'^skus/simple/$', images.ImageView.as_view({'get': 'simple'})),
    # sku商品查询
    re_path(r'^goods/(?P<pk>\d+)/specs/$', skus.SKUView.as_view({'get': 'specs'})),
    # 权限
    re_path(r'^permission/content_types/$', permission.PermissionView.as_view({'get': 'content_types'})),
    #
    re_path(r'^permission/simple/$', group.GroupView.as_view({'get': 'simple'})),
    # 分组
    re_path(r'^permission/groups/simple/$', admin.AdminView.as_view({'get': 'simple'})),

]
# ————————————————————规格————————————————————————————
# 自定义路由
router = DefaultRouter()
router.register('goods/specs', specs.SpecsView, basename='specs')

urlpatterns += router.urls

# ————————————————————图片————————————————————————————
# 自定义路由
router = DefaultRouter()
router.register('skus/images', images.ImageView, basename='images')

urlpatterns += router.urls
# ————————————————————SKU————————————————————————————
# 自定义路由
router = DefaultRouter()
router.register('skus', skus.SKUView, basename='skus')
urlpatterns += router.urls
# ————————————————————订单————————————————————————————
# 自定义路由
router = DefaultRouter()
router.register('orders', orders.OrdersView, basename='orders')
urlpatterns += router.urls
# ————————————————————权限————————————————————————————
# 自定义路由
router = DefaultRouter()
router.register('permission/perms', permission.PermissionView, basename='perms')
urlpatterns += router.urls
# ————————————————————组————————————————————————————
# 自定义路由
router = DefaultRouter()
router.register('permission/groups', group.GroupView, basename='groups')
urlpatterns += router.urls
# ————————————————————admin————————————————————————————
# 自定义路由
router = DefaultRouter()
router.register('permission/admins', admin.AdminView, basename='admins')
print(router.urls)
urlpatterns += router.urls
